﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NeoModulusBusinessRulesDLLBuilder.Classes;

namespace NeoModulusBusinessRulesDLLBuilder.Dialogs
{
    public partial class NewRelationshipWizard : Form
    {
        public List<ObjectDefinition> CurrentObjects { get; set; }
        public ObjectRelationship NewRelationship { get; set; }

        public NewRelationshipWizard()
        {
            InitializeComponent();
        }

        private void btnAddRelationship_Click(object sender, EventArgs e)
        {
            if (cbRelationship.SelectedItem != null && cbObject.SelectedItem != null)
            {
                NewRelationship = new ObjectRelationship();
                NewRelationship.ObjectDef = (ObjectDefinition)cbObject.SelectedItem;
                NewRelationship.RelationshipType = (ObjectRelationship.TypeOfRelationship)cbRelationship.SelectedItem;
            }
            else
            {
                this.DialogResult = DialogResult.Cancel;
            }

            this.Close();
        }

        private void NewRelationshipWizard_Load(object sender, EventArgs e)
        {
            cbRelationship.Items.Add(ObjectRelationship.TypeOfRelationship.Is);
            cbRelationship.Items.Add(ObjectRelationship.TypeOfRelationship.Contains);
            cbRelationship.Items.Add(ObjectRelationship.TypeOfRelationship.Uses);


            if (CurrentObjects != null)
            {
                cbObject.DataSource = CurrentObjects;
                cbObject.DisplayMember = "ObjectName";
            }
        }
    }
}

